﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class ModifyPsd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Name"] == null)
        {
            Response.Write("<script>alert('你还没登录，请先登录账号！');window.location.href='Logon.aspx';</script>");
        }
    }

    protected void BtnXGMM_Click(object sender, EventArgs e)
    {
        if (TxtPad.Text == "" && TxtRePad.Text == "")
        {
            Response.Write("<script>alert('密码不能为空！')</script>");
        }
        else
        {
            string Name = Session["Name"].ToString();
            int IdyID = Convert.ToInt32(Session["IdyID"].ToString());
            if (IdyID == 1 || IdyID == 2)
            {
                string sql = string.Format("update Doctor set PassWord='{0}' where ID='{1}'", this.TxtPad.Text, Name);
                DBHelper.GetNonQuery(sql);
                Response.Write("<script>alert('修改成功！');window.location.href='Logon.aspx';</script>");
            }
            else if (IdyID == 3)
            {
                string sql = string.Format("update Patient set PassWord='{0}' where IDCard='{1}' or Phone='{2}'", this.TxtPad.Text, Name, Name);
                DBHelper.GetNonQuery(sql);
                Response.Write("<script>alert('修改成功！');window.location.href='Logon.aspx';</script>");
            }
        }
    }

}